package com.neusoft.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.neusoft.bean.Student;
import com.neusoft.util.DBFactory;
import com.neusoft.util.JdbcUtil;

public class StuDao {
	public ArrayList<Student> getAll(){
		ArrayList<Student> list = new ArrayList<>();
		String sql = "select * from student";
		ResultSet rs = DBFactory.getJdbcUtil().doQuery(sql);
		try {
			while(rs.next()) {
				Student stu = new Student();
				stu.setStuNum(rs.getInt("stuNum"));
				stu.setStuName(rs.getString("stuName"));
				stu.setStuSex(rs.getString("stuSex"));
				stu.setStuAge(rs.getString("stuAge"));
				stu.setStuClazz(rs.getString("stuClazz"));
				list.add(stu);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}
}
